from Components.Component import Component

class CleanGlass(Component):

  def __call__(self, values):
  
      step_legend = ['1. Receive glass from manufacturers',
                     '2. Specify recipe',
                     '3. SRD (Spin/Rinse Dryer) load and unload',
                     '4. H2O DI Resistivity',
                     '5. Q: is it clean']
     
      # user input form
      input_dict = {'recipe':{'type':'dropdown', 'value':['Soap clean', 'Solvent clean', 'HCL clean', 'Nitric acid clean', 'Aqua Regia']}}

      # context info for this step [to show user]
      #output_dict = {'field1':'val1', 
      #               'field2':'val2'}
      output_dict = {}
      if 'actor_input' in values:
          for key, value in values['actor_input'][0].items():    # [{u'manuf_date': [u'xxxxxxxxxxxxxx']}]
              output_dict[key] = value
      #values['r'] = {'step_legend':step_legend, 'output_dict':output_dict, 'input_dict':input_dict}
  
  
      # put info on "conveyor belt" to circulate to all actors
      values['r'] = {'step_legend':step_legend, 'output_dict':output_dict, 'input_dict':input_dict}


      # go to next actor in workflow
      if 'actor_input' in values and len(values['actor_input'])>0:
          # debug
          print("\n*** values['actor_input'] in CleanGlass.py  ******")
          print(values['actor_input'])

          #values['r'] = {'step_legend':step_legend, 'output_dict':output_dict, 'input_dict':input_dict}
          values['r']['next_step'] = 3
          
          # go to next actor in workflow
          return (([self.get_connection()], values),)

      # loop on self 
      else: 
          print("\n*** CleanGlass.py: else clause  ******")
          values['status'] = "awaiting input"
          values['r']['next_step'] = 2
          
          # loop on self until values['square_x'] is received
          return (([self], values),) 


    